1. Field of the Invention
The present invention relates to a method, system, data structures, and article of manufacture for implementing a persistent object.
2. Description of the Related Art
An object is an entity with a set of possible states. The state of an object comprises the values of the attributes defined for the object. An application can apply methods to change the state of an object. For example, an application can change the state of an object by applying a method to change the value of an attribute defined for the object. When the application terminates, the object is destroyed and the state information is lost unless the application or the application environment saves the object in persistent storage such as files on a disk. When the state of an object outlives the execution of an application, the state of the object is called persistent, and the object is called a persistent object. When the application starts again, the application or the application environment restores the state of the persistent object from the persistent storage.
In an object-oriented system, a class is a collection of related objects and methods that operate on the objects. FIG. 1 shows selected prior art methods and a constructor of the public class Vector 400 (Java** vector class) of the Java programming language. The Java Vector class 400 is a collection of Java Vector objects and provides methods that can be used for typical operations on elements of the Java Vector objects such as add, delete, read, update etc. Details of the Java programming language are further described in “Java in a Nutshell”, by David Flanagan (Copyright O'Reilly & Associates, Inc., 1997), which publication is incorporated herein in reference in its entirety.
The Java Vector class 400 implements a growable array of objects. Like an array, the Java Vector class 400 contains components that can be accessed using an integer index. However, the size of a vector can grow or shrink as needed to accommodate adding and removing items after the vector has been created. The constructor Vector( ) 402 constructs an empty vector. The method elementAt(int) 404 returns the component at the specified index. The method addElement(Object) 406 adds the specified component to the end of a vector, increasing the size of the vector by one. The method removeElementAt(int) 408 deletes the component at the specified index. The method setElementAt(Object, int) 410 updates the component at the specified index of a vector to be the specified object. The method insertElementAt(Object, int) 412 inserts the specified object as a component in this vector at the specified index.
In prior art, there are indirect ways to create and save the state of persistent objects via object serialization. For classes that implement the serializable 414 interface, such as the Java Vector class 400, a programmer can modify the source code of an application to write the complete state of an object to a file output stream, and then recreate the object at a later time by reading the state of the object from the file's input stream. If serialized objects are written to a file's output stream, persistent objects are created. However, the methods in the Java Vector class 400 do not directly create and manipulate persistent objects. Hence, there is a need in the art to provide improved technologies for making vector objects, such as Java Vector objects, persistent.